if (ENABLE_ADDRESS_SANITIZER)
    add_cxx_compile_options(-fsanitize=address -fno-omit-frame-pointer)
    add_cxx_link_options(-fsanitize=address)
    add_swift_compile_options(-sanitize=address)
    add_swift_link_options(-sanitize=address)
endif()

if (ENABLE_MEMORY_SANITIZER)
    add_cxx_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer)
    add_cxx_link_options(-fsanitize=memory -fsanitize-memory-track-origins)
endif()

if (ENABLE_UNDEFINED_SANITIZER AND (APPLE OR NOT ENABLE_SWIFT))
    add_cxx_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
    if (UNDEFINED_BEHAVIOR_IS_FATAL)
        add_cxx_compile_options(-fno-sanitize-recover=undefined)
    endif()
    if (APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17")
        add_cxx_compile_options(-fno-sanitize=function)
    endif()
    add_cxx_link_options(-fsanitize=undefined)
    add_swift_compile_options(-sanitize=undefined)
    add_swift_link_options(-sanitize=undefined)
endif()
